package com.acme.data;

import java.util.List;

import org.hibernate.FlushMode;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.acme.domain.Parent;

public class ParentDaoImpl extends HibernateDaoSupport implements ParentDao {

	public void delete(Parent parent) {
		getSession().setFlushMode(FlushMode.AUTO);
		getHibernateTemplate().delete(parent);
		getSession().flush();
	}
	
	@SuppressWarnings("unchecked")
	public List<Parent> getAll() {
		List<Parent> find = getHibernateTemplate().find("from Parent");
		return find;
	}

	public Parent getById(String id) {
		return (Parent)getHibernateTemplate().get(Parent.class, id);
	}

	public void save(Parent parent) {
		getSession().setFlushMode(FlushMode.AUTO);
		getHibernateTemplate().saveOrUpdate(parent);
		getSession().flush();
	}

}
